Skip to content

ENH: Use circular weakref to delay copy in setitem #50902

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

lithomas1
Copy link
Member

@lithomas1 lithomas1 commented Jan 20, 2023

This PR uses a circular weakref between the added block in the DataFrame and the original block from the Series, when doing setitem in a DataFrame with a Series (haven't fixed other cases yet, wanted to get feedback on whether I'm on the right track).

With this way, whoever modifies the data first will have to copy the data, and we can delay the copy in __setitem__.

@lithomas1
Copy link
Member Author

cc @jorisvandenbossche @phofl for feedback.

@@ -4043,12 +4044,12 @@ def _iset_item_mgr(
self._mgr.iset(loc, value, inplace=inplace)
self._clear_item_cache()

def _set_item_mgr(self, key, value: ArrayLike) -> None:
def _set_item_mgr(self, key, value: ArrayLike, refs=[]) -> None:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we avoid a mutable default

@github-actions
Copy link
Contributor

This pull request is stale because it has been open for thirty days with no activity. Please update and respond to this comment if you're still interested in working on this.

@github-actions github-actions bot added the Stale label Feb 23, 2023
@lithomas1 lithomas1 closed this Feb 23, 2023
@lithomas1 lithomas1 deleted the cow-setitem-lazy branch March 14, 2023 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants